import * as zrender from "zrender";
import { unitWidth, halfUnitWidth } from '../config'

/**
 * 绘制今天线
 * @param {Object} zr ZRender实例
 * @param {number} chartStartX 图表起始X
 * @param {number} chartStartY 图表起始Y
 * @param {number} timeScaleHeight 时间轴高度
 * @param {number} barHeight 任务栏高度
 * @param {number} barMargin 任务栏间距
 * @param {number} todayOffset 今天偏移量
 * @param {Array} tasks 任务数组
 */
export function drawTodayLine(
  zr: any,
  chartStartX: number,
  chartStartY: number,
  timeScaleHeight: number,
  barHeight: number,
  barMargin: number,
  todayOffset: number, tasks: Task[]
) {
  const todayLine = new zrender.Rect({
    shape: {
      x: chartStartX + todayOffset * unitWidth - 1 + halfUnitWidth,
      y: chartStartY,
      width: 2,
      height: tasks.length * (barHeight + barMargin)
    },
    style: {
      fill: "#2955c9"
    },
    z: 1
  });
  const circle = new zrender.Circle({
    shape: {
      cx: chartStartX + todayOffset * unitWidth + halfUnitWidth,
      cy: chartStartY - timeScaleHeight + timeScaleHeight + 2,
      r: 3
    },
    style: {
      fill: "#2955c9"
    }
  })
  zr.add(todayLine);
  zr.add(circle);
}